package com.xinsoft.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinsoft.entity.dto.ScmStockMoveItemParam;
import com.xinsoft.entity.po.ScmStockMoveItem;
import com.xinsoft.entity.vo.ScmStockMoveItemVo;
import com.xinsoft.entity.vo.ScmStockMoveVo;
import com.xinsoft.service.ScmStockMoveItemService;
import com.xinsoft.mapper.ScmStockMoveItemMapper;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
* @author 13370
* @description 针对表【scm_stock_move_item(调拨明细)】的数据库操作Service实现
* @createDate 2023-08-17 09:52:00
*/
@Service
public class ScmStockMoveItemServiceImpl extends ServiceImpl<ScmStockMoveItemMapper, ScmStockMoveItem>
    implements ScmStockMoveItemService{

    @Override
    public List<ScmStockMoveItemVo> listPurchaseItem(ScmStockMoveItemParam itemParam) {
        List<ScmStockMoveItemVo> detailVOS = this.baseMapper.getDetail(itemParam);
        if (ObjectUtil.isNotEmpty(detailVOS)){
            detailVOS.forEach(item ->{
                item.setAssistUomNum((ObjectUtil.isEmpty(item.getMoveNum()) || item.getMoveNum().equals(BigDecimal.ZERO) || ObjectUtil.isEmpty(item.getConvCoefficient())) ?
                        BigDecimal.ZERO : item.getMoveNum().multiply(item.getConvCoefficient()));

            });
        }
        return detailVOS;
    }
}




